import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { FreightAccountService } from '../../../services/freight-account.service';

@Component({
  selector: 'app-abnormal-gold-detail',
  templateUrl: './abnormal-gold-detail.component.html',
  styleUrls: ['./abnormal-gold-detail.component.less']
})
export class AbnormalGoldDetailComponent implements OnInit {
  formData: any = {};

  constructor(public service: FreightAccountService, private route: ActivatedRoute) {
    const id = route.snapshot.params.id;
    this.loadRefundDetail(id);
  }

  ngOnInit(): void {}

  loadRefundDetail(id: string) {
    this.service.request(this.service.$api_get_getAbnormalAmount_detail, { id }).subscribe(res => {
      if (res) {
        this.formData = res;
      }
    });
  }

  downBack(bussType: string, receiptUrl: string) {
    if (this.formData?.refundStatus !== '3') {
      return;
    }
    this.service.getReceiptUrl(receiptUrl, {
      bankType: this.formData.bankType,
      rmYll: this.formData.userId,
      snglFlgCd: this.formData.coreSerNo,
      bussType,
      ltdId: this.formData.ltdId,
      accountType: this.formData.accountType
    });
  }

  goBack() {
    history.go(-1);
  }
}
